home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
oolregex
/
ctrlext.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1995-12-07
|
3KB
|
107 lines
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992-1995 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#include "stdafx.h"
#include "ctrlext.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define new DEBUG_NEW
/////////////////////////////////////////////////////////////////////////////
// Inline function declarations
#define _AFXCTL_INLINE inline
/////////////////////////////////////////////////////////////////////////////
// CTreeCtrlNode
const CTreeCursor& CTreeCursor::operator =(const CTreeCursor& posSrc)
{
if(&posSrc != this){
m_hTreeItem = posSrc.m_hTreeItem;
m_pTree = posSrc.m_pTree;
}
return *this;
}
CTreeCursor CTreeCursor::_Insert(LPCTSTR strItem,int nImageIndex,HTREEITEM hAfter)
{
TV_INSERTSTRUCT ins;
ins.hParent = m_hTreeItem;
ins.hInsertAfter = hAfter;
ins.item.mask = TVIF_TEXT;
ins.item.pszText = (LPTSTR) strItem;
if(nImageIndex != -1){
ins.item.mask |= TVIF_IMAGE | TVIF_SELECTEDIMAGE;
ins.item.iImage = nImageIndex;
ins.item.iSelectedImage = nImageIndex;
}
return CTreeCursor(m_pTree->InsertItem(&ins), m_pTree);
}
int CTreeCursor::GetImageID()
{
TV_ITEM item;
item.mask = TVIF_HANDLE | TVIF_IMAGE;
item.hItem = m_hTreeItem;
m_pTree->GetItem(&item);
return item.iImage;
}
/////////////////////////////////////////////////////////////////////////////
// CTreeCtrlEx
// All handled by inlines
/////////////////////////////////////////////////////////////////////////////
// CListCtrlEx
BOOL CListCtrlEx::AddColumn(LPCTSTR strItem,int nItem,int nSubItem,int nMask,int nFmt)
{
LV_COLUMN lvc;
lvc.mask = nMask;
lvc.fmt = nFmt;
lvc.pszText = (LPTSTR) strItem;
lvc.cx = GetStringWidth(lvc.pszText) + 15;
if(nMask & LVCF_SUBITEM){
if(nSubItem != -1)
lvc.iSubItem = nSubItem;
else
lvc.iSubItem = nItem;
}
return InsertColumn(nItem,&lvc);
}
BOOL CListCtrlEx::AddItem(int nItem,int nSubItem,LPCTSTR strItem,int nImageIndex)
{
LV_ITEM lvItem;
lvItem.mask = LVIF_TEXT;
lvItem.iItem = nItem;
lvItem.iSubItem = nSubItem;
lvItem.pszText = (LPTSTR) strItem;
if(nImageIndex != -1){
lvItem.mask |= LVIF_IMAGE;
lvItem.iImage |= LVIF_IMAGE;
}
if(nSubItem == 0)
return InsertItem(&lvItem);
return SetItem(&lvItem);
}
/////////////////////////////////////////////////////////////////////////////